<?php
/**
 * Object Main_Project_award
 * @author SillySmart
 * @copyright SillySmart
 * @package Mvc.Models.Objects
 * @see Sls.Models.Core.SLS_FrontModel
 * @since 1.0
 */
class Main_Project_award extends SLS_FrontModel
{
	/**
	 * Class variables
	 */
	protected $__project_award_id;
	protected $__pk_lang;
	protected $__project_id;
	protected $__project_award_label;
	protected $__project_award_value;
	protected $__project_award_url;
	protected $_table = "project_award";
	protected $_db = "main";
	protected $_primaryKey = "project_award_id";
	protected $_fks = array('project');
	public $_typeErrors = array();

	/**
	 * Constructor Main_Project_award
	 * @author SillySmart
	 * @copyright SillySmart
	 * @param bool $mutlilanguage true if multilanguage content, else false
	 */
	public function __construct($multilanguage=true)
	{
		parent::__construct($multilanguage);
		$this->buildDefaultValues();
	}

	/**
	 * Build default values for specific columns
	 * @author SillySmart
	 * @copyright SillySmart
	 */
	public function buildDefaultValues()
	{
	}

	/**
	 * Set the value of project_id
	 * Errors can be catched with the public variable $this->_typeErrors['project_id']
	 * @author SillySmart
	 * @copyright SillySmart
	 * @param int $value
	 * @return bool true if updated, false if not
	 */
	public function setProjectId($value)
	{
		$this->_generic->useModel("Project","main");
		$object = new Main_Project();
		if ($object->getModel($value) === false)
		{
			$this->_typeErrors['project_id'] = "E_KEY";
			return false;
		}
		$this->__set('project_id', $value);
		return true;
	}

	/**
	 * Set the value of project_award_label
	 * Errors can be catched with the public variable $this->_typeErrors['project_award_label']
	 * @author SillySmart
	 * @copyright SillySmart
	 * @param string $value
	 * @return bool true if updated, false if not
	 */
	public function setProjectAwardLabel($value)
	{
		if ($value === "")
		{
			$this->_typeErrors['project_award_label'] = "E_EMPTY";
			return false;
		}

		if (is_null($value))
		{
			$this->_typeErrors['project_award_label'] = "E_NULL";
			return false;
		}

		if ($this->__project_award_label == $value)
			return true;

		if (strlen($value) > 127)
		{
			$this->_typeErrors['project_award_label'] = "E_LENGTH";
			return false;
		}

		$this->__set('project_award_label', $value);
		return true;
	}

	/**
	 * Set the value of project_award_value
	 * Errors can be catched with the public variable $this->_typeErrors['project_award_value']
	 * @author SillySmart
	 * @copyright SillySmart
	 * @param string $value
	 * @return bool true if updated, false if not
	 */
	public function setProjectAwardValue($value)
	{
		if ($value === "")
		{
			$this->_typeErrors['project_award_value'] = "E_EMPTY";
			return false;
		}

		if (is_null($value))
		{
			$this->_typeErrors['project_award_value'] = "E_NULL";
			return false;
		}

		if ($this->__project_award_value == $value)
			return true;

		if (strlen($value) > 127)
		{
			$this->_typeErrors['project_award_value'] = "E_LENGTH";
			return false;
		}

		$this->__set('project_award_value', $value);
		return true;
	}

	/**
	 * Set the value of project_award_url
	 * Errors can be catched with the public variable $this->_typeErrors['project_award_url']
	 * @author SillySmart
	 * @copyright SillySmart
	 * @param string $value
	 * @return bool true if updated, false if not
	 */
	public function setProjectAwardUrl($value)
	{
		if (empty($value))
		{
			$this->__set('project_award_url', $value);
			return true;
		}

		if (!SLS_String::isValidUrl($value))
		{
			$this->_typeErrors['project_award_url'] = "E_TYPE";
			return false;
		}

		if ($this->__project_award_url == $value)
			return true;

		if (strlen($value) > 255)
		{
			$this->_typeErrors['project_award_url'] = "E_LENGTH";
			return false;
		}

		$this->__set('project_award_url', $value);
		return true;
	}

	/**
	 * Get the instance of Project's Model
	 * @author SillySmart
	 * @copyright SillySmart
	 * @return Main_Project $object the instance of Project's Model
	 */
	public function project()
	{
		$this->_generic->useModel("Project","main");
		$object = new Main_Project();
		$object->getModel($this->__project_id);
		return $object;
	}
}
?>